import Mock from 'mockjs'
// 2.自行模拟数据，开发相关接口
const data = Mock.mock({
  "tabList|4": [{
    "title": "@ctitle(2)",
    "url": "@image(100x100, @color)",
    "id": '@id',
    "children|10-20": [{
      "title": '@ctitle',
      "url": '@image(100x100, @color)',
      "banners|4-6": ["@image(100x100, @color)"],
      "desc": '@word(10,20)',
      "price|10-100": 1,
      "id": '@id'
    }]
  }],
  "searchList|10-30": [{
    "title": '@ctitle',
    "url": '@image(100x100, @color)',
    "banners|4-6": ["@image(100x100, @color)"],
    "desc": '@word(10,20)',
    "price|10-100": 1,
    "id": '@id'
  }]
})

// 2.自行模拟数据，开发相关接口
Mock.mock('/api/tab/list',() => {
  return {
    code: 200,
    data: data.tabList
  }
})

// 2.自行模拟数据，开发相关接口
Mock.mock('/api/search/list', 'post' ,(req) => {
  const { value = '' } = JSON.parse(req.body)
  const list = data.searchList.filter(item => item.title.includes(value))
  return {
    code: 200,
    data: list
  }
})